package eg.backend.repository.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import eg.backend.base.repository.EntityRepositoryImpl;
import eg.backend.domain.Budget;
import eg.backend.repository.BudgetRepository;

public class BudgetRepositoryImpl extends EntityRepositoryImpl<Budget, String> implements BudgetRepository {
	public List<Budget> findByCategories(List<String> categories, Date from,
			Date to, String user) {
		String queryName = "Budget.findByCategories";
		Map<String, Object> queryParams = new HashMap<String, Object>();
		queryParams.put("user", user);
		queryParams.put("from", from);
		queryParams.put("to", to);
		queryParams.put("categories", categories);
		return this.findByNamedQuery(queryName, queryParams);
	}

	public List<Budget> findByCategory(String category, Date from, Date to,
			String user) {
		List<String> categories = new ArrayList<String>();
		categories.add(category);
		return this.findByCategories(categories, from, to, user);
	}

	public Budget getByTag(Date from, String tag, Date to, String user) {
		String queryName = "Budget.getByTag";
		Map<String, Object> queryParams = new HashMap<String, Object>();
		queryParams.put("user", user);
		queryParams.put("from", from);
		queryParams.put("to", to);
		queryParams.put("tag", tag);
		return this.getByNamedQuery(queryName, queryParams);
	}

}
